#include "circleQueue.h"

int initIdQueue(idQueue_t* pIdQueue){
    bzero(pIdQueue, sizeof(pIdQueue));
    pIdQueue->queueSize = 0;
    pIdQueue->pFront = NULL;
    pIdQueue->pRear = NULL;
}

int idEnQueue(idQueue_t* pIdQueue, int id){
    Id_t *node = (Id_t *)calloc(1, sizeof(Id_t));
    node->id = id;
    node->pNext = NULL;
    if(pIdQueue->queueSize == 0){
        pIdQueue->pFront = node;
    }
    else{
        pIdQueue->pRear->pNext = node;
    }
    pIdQueue->pRear = node;
    pIdQueue->queueSize++;
    return 0;
}

int idDeQueue(idQueue_t* pIdQueue){
    Id_t *pDel = pIdQueue->pFront;
    int id = pDel->id;
    pIdQueue->pFront = pIdQueue->pFront->pNext;
    free(pDel);
    --pIdQueue->queueSize;
    if(pIdQueue->queueSize == 0){
        pIdQueue->pRear = NULL;
    }
    return id;
}